Coin “Thump” Example

Suppose that we “thump” a “fair” coin ten times. For testing \(\mbox{H}_0 : p = 0.5\) versus the one-sided alternative \(\mbox{H}_1 : p > 0.5\) at the \(\alpha = 0.05\) level we note that \(P(X>7 | p = 0.5) = 1 - P(X \le 7 | p = 0.5) =\)

  1 - pbinom(7, 10, 0.5)
## [1] 0.0546875
  pbinom(7, 10, 0.5, lower.tail = FALSE)
## [1] 0.0546875

Since 0.0546875 \(> \alpha = 0.05\) we check \(P(X > 8 | p = 0.5) = 1 - P(X \le 7 | p = 0.5) =\)

  1 - pbinom(8, 10, 0.5)
## [1] 0.01074219
  pbinom(8, 10, 0.5, lower.tail = FALSE)
## [1] 0.01074219

Since 0.0546875 \(> \alpha = 0.05\) we reject \(\mbox{H}_0\) when \(X > 8\), “flip a coin” with \(P(\mbox{reject}) = p^*\) when \(X = 8\), and do not reject \(\mbox{H}_0\) when \(X \le 7\).

To find \(p^*\) we note that \[ \begin{align*} P(\mbox{rej}\ \mbox{H}_0 | p=0.5) &= 0 \cdot P(X \le 7) + 0.8952 \cdot P(X=8) + 1 \cdot P(X > 8) \\ &= 0 + 0.0393 + 0.017 \\ &= 0.05 \end{align*} \]

So randomizer coin has probability \(p^* = 0.8952\) of causing rejection.

Power

Suppose that we choose \(\zeta = \{ 8, 9, 10\}\) — without randomization at 8. Then \(\alpha = P(\mbox{rej}\ \mbox{H}_0 | p=0.5) = 0.0547\)

  pstar <- seq(0, 1, by=0.1)
  power <- 1 - pbinom(7, 10, pstar)
  print(data.frame(pstar, power = round(power,4)))
##    pstar  power
## 1    0.0 0.0000
## 2    0.1 0.0000
## 3    0.2 0.0001
## 4    0.3 0.0016
## 5    0.4 0.0123
## 6    0.5 0.0547
## 7    0.6 0.1673
## 8    0.7 0.3828
## 9    0.8 0.6778
## 10   0.9 0.9298
## 11   1.0 1.0000

We can plot the power curve for various “true” \(p\) when testing \(\mbox{H}_0 : p \le p_0=0.5\) versus \(\mbox{H}_1 : p > p_0=0.5\).

  p <- seq(0,1,by=0.001)
  power <- 1 - pbinom(7, 10, p)
  plot(p, power, type="l")
  abline(v=0.5, lty=2)
  abline(h=0.05, lty=2, col="red") ### Desired alpha
  abline(h=1-pbinom(7,10,0.5), lty=2, col="green")  ### True alpha

  (1-pbinom(7, 10, 0.5)) - 0.05 ### Difference between true and desired alpha
## [1] 0.0046875

Note that as \(p\) increases (moves further away from \(\omega\) and into \(\Theta - \omega\)) our power (\(1 - \beta\)) increases. This is a good thing.